import java.util.Arrays;

/*
//冒泡排序和反转排序的使用

public class Main{
    public static void main(String[] args){
        int[] arr = new int[]{71,89,67,53,78,64,92,56,74,85};
        mao_sort(arr);
        print(arr);

        reverse_sort(arr);
        print(arr);

    }
    //打印函数模块
    public static void print(int[] arr){
        int i;
        for(i = 0; i < arr.length; i++){
            System.out.print(arr[i] + " ");
        }
        System.out.println();
    }
    //冒泡排序从大到小模块
    public static void mao_sort(int[] arr){
        int n = arr.length;
        int i,j;
        for(i = 0; i < n-1; i++){
            for(j = 0; j < n - i -1; j++){
                if(arr[j] < arr[j + 1]){
                    int temp = arr[j];
                    arr[j] = arr[j +1];
                    arr[j + 1] = temp;
                }
            }
        }
    }
    //反转函数模块
    public static void reverse_sort(int[] arr){
        int i,j;
        for(i = 0; i < arr.length-1; i++){
            for(j = 0; j < arr.length /2 ; j++){
                int temp = arr[j];
                arr[j] = arr[arr.length -1 -j];
                arr[arr.length - 1 - j] = temp;
            }
        }
    }
}
 */

/*
import java.util.Scanner;

//数独
//将1~9的数字放入一个 3*3 的数组中，
//判断该数组的每行每列以及没个对角线的值相加是否都相等

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int row = 3;
        int col = 3;
        int[][] arr = new int[row][col];
        int i,j;
        for(i = 0; i < row; i++){
            for(j = 0; j < col; j++){
                arr[i][j] = sc.nextInt();
            }
        }
        int a =my_if(arr);
        if(a == 1){
            System.out.println("这个3*3的数组是：数独");
        }
        else{
            System.out.println("这个3*3的数组不是数独");
        }
    }
    //判断
    public static int my_if(int[][] arr){

        //int a = arr[0][0] + arr[0][1] + arr[0][2];
        //int b = arr[1][0] + arr[1][1] + arr[1][2];
        //int c = arr[2][0] + arr[2][1] + arr[2][2];

        int j;
        //行
        int a,b,c;
        a = 0; b = 0; c = 0;
        //列
        int x,y,z;
        x = 0; y = 0; z = 0;
        //斜对角线的值
        int l = arr[0][0]+arr[1][1]+arr[2][2];
        int k = arr[0][2]+arr[1][1]+arr[2][0];

        for(j = 0; j < 3 ;j++){
            a += arr[0][j];
            b += arr[1][j];
            c += arr[2][j];

            x += arr[j][0];
            y += arr[j][1];
            z += arr[j][2];
        }
        if(a == b && b == c && x == y && y == z && x == a){
            if(l == k && a == l){
                return 1;
            }
        }
        return 0;
    }
}
 */

/*
//矩阵转置
public class Main{
    public static void main(String[] args){
        int[][] arr = new int[][]{{91,25,8},{56,14,2},{47,3,67}};
        int i ,j;
        for(i = 0;i<arr.length;i++){
            for(j = 0; j<arr[i].length;j++){
                System.out.print(arr[j][i]+"  ");
            }
            System.out.println();
        }
    }
}
 */

/*
//杨辉三角

public class Main{
    public static void main(String[] args){
        int[][] arr = triangle(10);
        print(arr);

    }
    public static int[][] triangle(int n){
        int[][] arr = new int[n][n];
        int i,j;
        for(i = 0;i < arr.length;i++){
            arr[i][0] = arr[i][i] = 1;
        }
        for(i = 2; i < 10; i++){
            for(j = 1; j <= i; j++){
                arr[i][j] = arr[i-1][j] + arr[i-1][j-1];
            }
        }
        return arr;
    }
    public static void print(int[][] arr){
        int i,j;
        for(i = 0; i < arr.length;i++){

            for(j = 0; j <arr.length - i - 1;j++){
                System.out.print("   ");
            }
            for(j = 0; j <= i; j++){
                System.out.print("   ");
                System.out.printf("%-3d",arr[i][j]);
            }
            System.out.println();
        }
    }
}

 */

/*
import java.util.Scanner;
//统计学生成绩，输入学生的学号及语文，数学，英语成绩和总成绩

public class Main{
    public static void main(String[] args){
        do{
            Scanner sc = new Scanner(System.in);
            System.out.print("请输入第3个学生的编号：");
            int a = sc.nextInt();

            //输入语文成绩
            Scanner sc1 = new Scanner(System.in);
            System.out.print("请输入语文成绩：");
            int x = sc1.nextInt();
            //输入数学成绩
            Scanner sc2 = new Scanner(System.in);
            System.out.print("请输入数学成绩：");
            int y = sc2.nextInt();
            //输入英语成绩
            Scanner sc3 = new Scanner(System.in);
            System.out.print("请输入英语成绩：");
            int z = sc3.nextInt();

            menu();
            print(a,x,y,z);

        }while(true);
    }
    public static void print(int a,int x,int y,int z){
        int[] arr = new int[]{a,x,y,z,(x+y+z)/3,x+y+z};
        int i ;
        for(i = 0; i < arr.length;i++){
            System.out.printf("%4d\t",arr[i]);
        }
        System.out.println();
    }
    public static void menu(){
        System.out.println("学生成绩如下：");
        System.out.println("-----------------------------------------------------");
        System.out.println("学生编号  语文成绩  数学成绩  英语成绩  平均成绩  总成绩");
        System.out.println("  1       97      80      99      92      276");
        System.out.println("  2       95      88      94      92      277");
    }
}

 */


//模拟客车售票
//一辆大巴9排4列的座位
//模拟这辆大巴的售票过程（1代表“有票”，0代表“无票”）;

import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        int[][] arr=new int[][]{
                {1,1,1,1},
                {1,1,1,1},
                {1,1,1,1},
                {1,1,1,1},
                {1,1,1,1},
                {1,1,1,1},
                {1,1,1,1},
                {1,1,1,1},
                {1,1,1,1},
        } ;
        do{
            menu();
            print(arr);
            Scanner sc1 = new Scanner(System.in);
            System.out.print("请输入要预定座位的行号：");
            int n = sc1.nextInt();
            System.out.println();
            Scanner sc2 = new Scanner(System.in);
            System.out.print("请输入要预定座位的列号：");
            int m = sc2.nextInt();
            System.out.println();

            if(arr[n-1][m-1] == 1){
                arr[n-1][m-1] = 0;
                System.out.println("购票成功！");
            }
            else{
                System.out.println("这个座位已经预定请换一个座位吧！");
            }

        }while(true);
    }
    public static void menu(){
        System.out.println("     客车售票系统     ");
        System.out.println(" 9排4列的大巴车开始售票 ");
    }
    public static void print(int[][] arr){
        int i,j;
        for(i = 0; i < arr.length; i++){
            for(j = 0; j < arr[i].length; j++){
                System.out.printf("%3d",arr[i][j]);
            }
            System.out.println();
        }
    }
}

